package com.zhihaihe.file.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 统一返回对象
 * @author
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class R<T> {
    private boolean success;
    private Integer code;
    private String message;
    private T data;

    public static<T> R fail(Integer code,String message,T data) {
       return new R<>(false,code,message,data);
    }

    public static<T> R fail(String message) {
        return new R<>(false,ResultCodeEnum.UNKNOWN_ERROR.getCode(),message,null);
    }

    public static<T> R success(String message,T data) {
        return new R<>(true,20000,message,data);
    }
    public static<T> R success(T data) {
        return success(null,data);
    }
}
